//Page Object
import {
  request
} from '../../request/index.js'
Page({
  data: {
    swiperList: [],
    cateList: [],
    floorList: []
  },
  //options(Object)
  onLoad: function (options) {
    this.getSwiperList()
    this.getCateList()
    this.getFloorList()
  },
   // 下拉刷新事件 
   async onPullDownRefresh(){
    //   uni.showLoading({ title: '数据拼命加载中...'})
    await Promise.all([this.getSwiperList(), this.getCateList(), this.getFloorList()]);
    //   uni.hideLoading();
    wx.stopPullDownRefresh();
   },
  // 获取轮播图数据
  async getSwiperList() {
    const swiperList = await request({
      url: "/home/swiperdata",
    })
    this.setData({
      swiperList
    })
  },
  // 获取 分类导航数据
  async getCateList() {
    const cateList = await request({
      url: "/home/catitems",
    })
    this.setData({
      cateList
    })
  },
  // 获取 楼层数据
  async getFloorList() {
    const floorList = await  request({
      url: "/home/floordata",
    }) 
    this.setData({
      floorList
    })
  }
});